<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>图文管理 - 派后台管理系统</title>
    {include file="public/header" /}
</head>
<body>
<div class="container-fluid p-t-15">
    <div class="row">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-body">
                    <form class="form-inline searchForm">
                        <div class="form-group">
                            <label for="title">关键词</label>
                            <div class="input-group">
                                <div class="input-group">
                                    <input type="text" class="form-control" id="title" value="" autocomplete="off" name="title" placeholder="请输入文章标题">
                                </div>
                            </div>
                        </div>
                        <button type="submit" class="btn btn-success" style="margin: -10px 0 0 10px;" id="search">搜索</button>
                        <button type="button" class="btn btn-success" style="margin: -10px 0 0 10px;" onclick="iframe.createIframe('添加图文','/admin/wechat.wechat_news/add')">添加</button>
                        <button type="button" class="btn btn-success" style="margin: -10px 0 0 10px;" id="sync">同步</button>
                    </form>
                </div>
            </div>
        </div>
        <div class="col-lg-12">
            <div class="card">
                <div class="card-header"><h4>图文列表</h4></div>
                <div class="card-body">
                    <div class="row">
                        {volist name="item" id="vo"}
                        <div class="col-lg-3 col-md-4 col-sm-6 item-card">
                            <h1 class="item-title">{$vo.cover.title}</h1>
                            <div class="item-image"><img src="{$vo.cover.thumb_url}"></div>
                            <div class="item-desc">{$vo.cover.digest}</div>
                            <div class="item-footer"><span>更新于{$vo.update_time|date='Y-m-d'}</span><span style="float: right;"><a onclick="iframe.createIframe('编辑图文','/admin/wechat.wechat_news/add?id={$vo.id}')"><span class="mdi mdi-table-edit item-footer-icon"></span></a><a onclick="del('{$vo.id}')"><span class="mdi mdi-delete-circle item-footer-icon"></span></a></span></div>
                        </div>
                        {/volist}
                    </div>
                    {$item|raw}
                </div>
            </div>
        </div>
    </div>
</div>
</body>
{include file="public/footer"/}
<script>
    $("#sync").click(function () {
        $.post("/admin/wechat.wechat_news/sync",{},function (res) {
            if (res.status == 200) {
                parent.lightyear.notify(res.msg, 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
                location.reload();
            }
            else parent.lightyear.notify(res.msg, 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
        });
    });
    function del(id) {
        $.confirm({
            title: '重要提醒!',
            content: '您正在删除文章，该操作不可逆！' ,
            backgroundDismiss: true,
            buttons: {
                ok: {
                    text: '确认',
                    btnClass: 'btn-danger',
                    action: function () {
                        $.get("/admin/wechat.wechat_news/del",{id:id},function (res) {
                            if (res.status == 200) {
                                parent.lightyear.notify(res.msg, 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
                                location.reload();
                            }
                            else parent.lightyear.notify(res.msg, 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
                        });
                    }
                },
                cancel: {
                    text: '取消',
                    btnClass: 'btn-primary'
                }
            }
        });
    }
</script>
<style>
    .item-title{
        font-size: 16px;
    }
    .item-card{
        margin: auto;
        max-width: 320px;
        padding: 10px;
        box-shadow: 0 1px 20px 0 rgba(0, 0, 0, 0.1);
        border-radius: 2px;
    }
    .item-desc{
        padding: 10px 0;
        font-size: 14px;
        color: #848484;
    }
    .item-footer{
        line-height: 50px;
    }
    .item-image img{
        max-width: 100%;
    }
    .item-footer-icon{
        font-size: 20px;
        margin-left: 10px;
    }
</style>
</html>